﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Diagnostics;
namespace vpn
{
    public class Consts
    {
        public static string TaobaoLink = "http://item.taobao.com/item.htm?id=13912590732";
        public static string DefaultUser = "vpn";
        public static string DefaultUserPass = "vpnpas";
        public static string VPN_website = "www.vpnsrvs.com";
        public static string DefaultServer = "50.18.143.47";
#if Debug
        public static int MaxTrailCnt = 100;
#else
        public static int MaxTrailCnt = 3;
#endif
    }

    public delegate bool EventConnect(string Server, string VPNName, string username, string password);
    public delegate bool Disconnect(string VPNName);

    public class ConnectionManager
    {
        static public EventConnect _Connect = null;
        static public Disconnect _DisConnect = null;

        public ConnectionManager()
        {
        }

        public bool Connect(string Server, string VPNName, string username, string password)
        {
            if(null != _Connect)
                _Connect(Server, VPNName, username, password);
            return true;
        }

        public bool Disconnect(string VPNName)
        {
            if (null != _DisConnect)
                _DisConnect(VPNName);

            return true;
        }
    }

    public class Utils
    {
        public static void StartProcess(string path)
        {
            if (!System.IO.File.Exists(path))
                return;

            ProcessStartInfo myProcess = new ProcessStartInfo(path);
            myProcess.CreateNoWindow = true;
            myProcess.UseShellExecute = false;
            Process.Start(myProcess);
        }

        //C#判断操作系统是否为WindowsXP
        public static bool IsWindowsXP
        {
            get
            {
                return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 1);
            }
        }

        //C#判断操作系统是否为WindowsVista
        public static bool IsWindowsVista
        {
            get
            {
                return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor == 0);
            }
        }
        //C#判断操作系统是否为Windows7
        public static bool IsWindows7
        {
            get
            {
                return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor == 1);
            }
        }
    }
}
